package com.ece.demo.normal;

import dev.ece.core.cells.model.base.SquareModel;
import dev.ece.core.shader.DepthShader;
import dev.ece.core.sprite.Sprite;
import dev.ece.core.texture.Texture;
import dev.ece.util.tools.Camera;

/**
 * @author 潜行的青衣
 * @see
 */
public class SquareSprite extends Sprite<Object, SquareModel> {
	
	private DepthShader depthShader = DepthShader.getDepthShader();
	
	private NormalMapShader shader;
	
	private Texture texture;
	
	private Texture normal;
	
	/**
	 * @param model
	 */
	public SquareSprite(SquareModel model, Texture textrue, Texture normal, NormalMapShader shader) {
		super(model);
		this.texture = textrue;
		this.shader = shader;
		this.normal = normal;
	}

	@Override
	public void onRenderDepthMap(Camera camera) {
		depthShader.glUseProgram();
		depthShader.glModelViewProjectMatrix();
		super.onRenderDepthMap(camera);
	}

	@Override
	public void onRender(Camera camera) {
		this.shader.glUseProgram();
		this.shader.glModelViewProjectMatrix();
		this.shader.glMaterial(this.getModel().getMaterial());
		this.shader.glTexture(texture);
		this.shader.glNormal(normal);
		super.onRender(camera);
	}

}
